<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>Python学习笔记 | Jixer的小屋</title><meta name="author" content="Jixer"><meta name="copyright" content="Jixer"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="注意：建议配合Python教程书本来结合学习 一.Python的安装与环境搭建 Python官网下载：https:&#x2F;&#x2F;www.python.org&#x2F; 安装与环境搭建请看教程：https:&#x2F;&#x2F;cloud.tencent.com&#x2F;developer&#x2F;article&#x2F;1580729 注意：必须是在cmd中输入python有输出显示才算的上是环境搭建成功 二.第一个Python程序1print(&amp;quot">
<meta property="og:type" content="article">
<meta property="og:title" content="Python学习笔记">
<meta property="og:url" content="http://www.lijunxi.site/posts/695896537/index.html">
<meta property="og:site_name" content="Jixer的小屋">
<meta property="og:description" content="注意：建议配合Python教程书本来结合学习 一.Python的安装与环境搭建 Python官网下载：https:&#x2F;&#x2F;www.python.org&#x2F; 安装与环境搭建请看教程：https:&#x2F;&#x2F;cloud.tencent.com&#x2F;developer&#x2F;article&#x2F;1580729 注意：必须是在cmd中输入python有输出显示才算的上是环境搭建成功 二.第一个Python程序1print(&amp;quot">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://q1.qlogo.cn/g?b=qq&nk=2770063826&s=640">
<meta property="article:published_time" content="2024-01-17T05:40:31.000Z">
<meta property="article:modified_time" content="2024-05-07T03:10:23.263Z">
<meta property="article:author" content="Jixer">
<meta property="article:tag" content="Python">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://q1.qlogo.cn/g?b=qq&nk=2770063826&s=640"><link rel="shortcut icon" href="/img/logo/favicon.ico"><link rel="canonical" href="http://www.lijunxi.site/posts/695896537/index.html"><link rel="preconnect"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css?v=4.13.0"><link rel="stylesheet" href="/pluginsSrc/@fortawesome/fontawesome-free/css/all.min.css?v=6.5.1"><link rel="stylesheet" href="/pluginsSrc/@fancyapps/ui/dist/fancybox/fancybox.css?v=5.0.33" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  infinitegrid: {
    js: '/pluginsSrc/@egjs/infinitegrid/dist/infinitegrid.min.js?v=4.11.1',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Python学习笔记',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2024-05-07 11:10:23'
}</script><script>(win=>{
      win.saveToLocal = {
        set: (key, value, ttl) => {
          if (ttl === 0) return
          const now = Date.now()
          const expiry = now + ttl * 86400000
          const item = {
            value,
            expiry
          }
          localStorage.setItem(key, JSON.stringify(item))
        },
      
        get: key => {
          const itemStr = localStorage.getItem(key)
      
          if (!itemStr) {
            return undefined
          }
          const item = JSON.parse(itemStr)
          const now = Date.now()
      
          if (now > item.expiry) {
            localStorage.removeItem(key)
            return undefined
          }
          return item.value
        }
      }
    
      win.getScript = (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        script.onerror = reject
        script.onload = script.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          script.onload = script.onreadystatechange = null
          resolve()
        }

        Object.keys(attr).forEach(key => {
          script.setAttribute(key, attr[key])
        })

        document.head.appendChild(script)
      })
    
      win.getCSS = (url, id = false) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onerror = reject
        link.onload = link.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          link.onload = link.onreadystatechange = null
          resolve()
        }
        document.head.appendChild(link)
      })
    
      win.activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
        if (t === 'dark') activateDarkMode()
        else if (t === 'light') activateLightMode()
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
      const detectApple = () => {
        if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
          document.documentElement.classList.add('apple')
        }
      }
      detectApple()
    })(window)</script><link rel="stylesheet" href="/css/custom-all-min.css"><link rel="stylesheet" href="/css/custom-fancybox-min.css"><link rel="stylesheet" href="/css/custom-share-min.css"><meta name="generator" content="Hexo 6.3.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><script>(()=>{
  const $loadingBox = document.getElementById('loading-box')
  const $body = document.body
  const preloader = {
    endLoading: () => {
      $body.style.overflow = ''
      $loadingBox.classList.add('loaded')
    },
    initLoading: () => {
      $body.style.overflow = 'hidden'
      $loadingBox.classList.remove('loaded')
    }
  }

  preloader.initLoading()
  window.addEventListener('load',() => { preloader.endLoading() })

  if (false) {
    document.addEventListener('pjax:send', () => { preloader.initLoading() })
    document.addEventListener('pjax:complete', () => { preloader.endLoading() })
  }
})()</script><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="" data-original="https://q1.qlogo.cn/g?b=qq&amp;nk=2770063826&amp;s=640" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">52</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">19</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">7</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-graduation-cap"></i><span> 文章</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-archive"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/archives/"><i class="fa-fw fa fa-folder-open"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/links/"><i class="fa-fw fa fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header"><nav id="nav"><span id="blog-info"><a href="/" title="Jixer的小屋"><span class="site-name">Jixer的小屋</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-graduation-cap"></i><span> 文章</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-archive"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/archives/"><i class="fa-fw fa fa-folder-open"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/links/"><i class="fa-fw fa fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Python学习笔记</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2024-01-17T05:40:31.000Z" title="发表于 2024-01-17 13:40:31">2024-01-17</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-05-07T03:10:23.263Z" title="更新于 2024-05-07 11:10:23">2024-05-07</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">学习笔记</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.6k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>5分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Python学习笔记"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><p><strong><em>注意：建议配合Python教程书本来结合学习</em></strong></p>
<h3 id="一-Python的安装与环境搭建"><a href="#一-Python的安装与环境搭建" class="headerlink" title="一.Python的安装与环境搭建"></a>一.Python的安装与环境搭建</h3><p> Python官网下载：<a target="_blank" rel="noopener" href="https://www.python.org/">https://www.python.org/</a></p>
<p>安装与环境搭建请看教程：<a target="_blank" rel="noopener" href="https://cloud.tencent.com/developer/article/1580729">https://cloud.tencent.com/developer/article/1580729</a></p>
<p><strong><em>注意：必须是在cmd中输入python有输出显示才算的上是环境搭建成功</em></strong></p>
<h3 id="二-第一个Python程序"><a href="#二-第一个Python程序" class="headerlink" title="二.第一个Python程序"></a>二.第一个Python程序</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">print(&quot;Hello World!&quot;)</span><br></pre></td></tr></table></figure>

<p>简简单单输出：Hello World!</p>
<h3 id="三-Python的基础语法"><a href="#三-Python的基础语法" class="headerlink" title="三.Python的基础语法"></a>三.Python的基础语法</h3><h4 id="1-Python的标识符"><a href="#1-Python的标识符" class="headerlink" title="1.Python的标识符"></a>1.<strong>Python的标识符</strong></h4><ul>
<li>第一个字符必须是字母表中字母或下划线</li>
<li>标识符的其他的部分由字母、数字和下划线组成</li>
<li>标识符对大小写敏感</li>
</ul>
<h4 id="2-Python的关键字"><a href="#2-Python的关键字" class="headerlink" title="2.Python的关键字"></a>2.<strong>Python的关键字</strong></h4><ul>
<li>关键词：保留字，我们不能用它来做任何表示符名称</li>
<li>Python的关键字：如下</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">True，False，None，and，as，asset ，def ，class ，continue ，break ，else ，finally ，elif ，del ，except ，global ，for ，if ，from ，import ，raise ，try ，or ，return ，pass ，nonlocal ，in ，not ，is ，lambda</span><br></pre></td></tr></table></figure>

<h4 id="3-Python的注释"><a href="#3-Python的注释" class="headerlink" title="3.Python的注释"></a>3.<strong>Python的注释</strong></h4><ul>
<li>注释：编译器不执行此语句</li>
<li>单行注释：用 # 来表示</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">#print(&quot;此处是单行注释&quot;)</span><br></pre></td></tr></table></figure>

<ul>
<li>  多行注释：用 ‘ 或者 “ 来表示</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">&#x27;print(&quot;此处是多行注释&quot;)&#x27; </span><br><span class="line">&quot;print(&quot;此处也是多行注释&quot;)&quot;</span><br></pre></td></tr></table></figure>

<h4 id="4-Python的缩进"><a href="#4-Python的缩进" class="headerlink" title="4.Python的缩进"></a>4.<strong>Python的缩进</strong></h4><ul>
<li>  Python的缩进与其他编程语言不同，它是强制性的，必须通过Tab来与语句对齐,否则会报错!</li>
</ul>
<h3 id="四-Python的基本数据类型"><a href="#四-Python的基本数据类型" class="headerlink" title="四.Python的基本数据类型"></a>四.Python的基本数据类型</h3><h4 id="1-Python中的数据类型"><a href="#1-Python中的数据类型" class="headerlink" title="1.Python中的数据类型"></a>1.<strong>Python中的数据类型</strong></h4><ul>
<li>整型：整数</li>
<li>字符型：字符串</li>
<li>浮点型：小数</li>
<li>列表：[], list()</li>
<li>元组：(), tuple()</li>
<li>集合：set()</li>
<li>字典：{}, dict()</li>
</ul>
<h4 id="2-每个数据类型之间能相互转换"><a href="#2-每个数据类型之间能相互转换" class="headerlink" title="2. 每个数据类型之间能相互转换"></a>2. <strong>每个数据类型之间能相互转换</strong></h4><ul>
<li>int(x)—&gt;x转为整型</li>
<li>str(x)—&gt;x转为字符型</li>
<li>float(x)—&gt;x转为浮点型</li>
<li>list(x)—&gt;x转为列表</li>
<li>tuple(x)—&gt;x转为元组</li>
<li>set(x)—&gt;x转为集合</li>
<li>dict(x)—&gt;x转为字典</li>
</ul>
<p><em>注意：有的转换必须符合转换的要求！不想这么转就怎么转</em></p>
<h3 id="五-条件判断语句（比较简单就不再过多叙述）"><a href="#五-条件判断语句（比较简单就不再过多叙述）" class="headerlink" title="五.条件判断语句（比较简单就不再过多叙述）"></a>五.条件判断语句（比较简单就不再过多叙述）</h3><h4 id="格式："><a href="#格式：" class="headerlink" title="格式："></a><strong>格式：</strong></h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">if (条件一):</span><br><span class="line">     (表达式一)</span><br><span class="line">elif (条件二):</span><br><span class="line">     (表达式二)</span><br><span class="line">else:</span><br><span class="line">     (表达式三)</span><br></pre></td></tr></table></figure>

<h3 id="六-循环语句（比较简单就不再过多叙述）"><a href="#六-循环语句（比较简单就不再过多叙述）" class="headerlink" title="六.循环语句（比较简单就不再过多叙述）"></a>六.循环语句（比较简单就不再过多叙述）</h3><h4 id="1-while循环"><a href="#1-while循环" class="headerlink" title="1.while循环"></a>1.while循环</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">while (满足循环进行的条件):</span><br><span class="line">       (表达式一)</span><br></pre></td></tr></table></figure>

<h4 id="2-for循环"><a href="#2-for循环" class="headerlink" title="2.for循环"></a>2.for循环</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">for i in x:    #此处的x可以为列表，字典，字符换等, i为自变量</span><br><span class="line">       (表达式一)</span><br><span class="line">for i in range(0,x):  #表示循环x次，x必须为整数</span><br><span class="line">       (表达式二)  </span><br></pre></td></tr></table></figure>

<h3 id="七-列表"><a href="#七-列表" class="headerlink" title="七.列表"></a>七.列表</h3><h4 id="1-列表的创建"><a href="#1-列表的创建" class="headerlink" title="1.列表的创建"></a>1.<strong>列表的创建</strong></h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">a = list()   #两种方法都可以</span><br><span class="line">a = []</span><br></pre></td></tr></table></figure>

<h4 id="2-列表的操作"><a href="#2-列表的操作" class="headerlink" title="2.列表的操作"></a>2.<strong>列表的操作</strong></h4><ul>
<li>访问</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a[0]    #代表列表a的下标为1的元素</span><br></pre></td></tr></table></figure>

<ul>
<li>增加</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.append(x)   #x代表增加的元素</span><br></pre></td></tr></table></figure>

<ul>
<li>删除</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">del a[x]   #x代表元素下标的索引</span><br></pre></td></tr></table></figure>

<ul>
<li>更新</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a[5] = 6   #把下标索引为5的元素改为整数6</span><br></pre></td></tr></table></figure>

<ul>
<li>列表的长度</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">len(a)</span><br></pre></td></tr></table></figure>

<ul>
<li>列表的最大值</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">max(a)</span><br></pre></td></tr></table></figure>

<ul>
<li>列表的最小值</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">min(a)</span><br></pre></td></tr></table></figure>

<ul>
<li>某元素出现的次数</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.count(x) #x为某一元素</span><br></pre></td></tr></table></figure>

<ul>
<li>列表排序</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.sort(key=None,reverse=False)   #对列表从小到大排序,reverse=True为降序</span><br></pre></td></tr></table></figure>

<ul>
<li>列表反转</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.reverse()  #反向列表中元素</span><br></pre></td></tr></table></figure>

<ul>
<li>清空列表</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.clear()</span><br></pre></td></tr></table></figure>

<ul>
<li>复制列表</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.copy()</span><br></pre></td></tr></table></figure>

<ul>
<li>取出第i位并删除</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.pop(i)</span><br></pre></td></tr></table></figure>

<ul>
<li>在列表第i位插入x</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.insert(i,x)</span><br></pre></td></tr></table></figure>

<ul>
<li>将列表出现的第一个元素x删除</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.remove(x)</span><br></pre></td></tr></table></figure>

<ul>
<li>将列表b添加到列表a中</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.extend(b)</span><br></pre></td></tr></table></figure>

<h3 id="八-元组"><a href="#八-元组" class="headerlink" title="八.元组"></a>八.元组</h3><h4 id="1-元组的创建"><a href="#1-元组的创建" class="headerlink" title="1.元组的创建"></a><strong>1.元组的创建</strong></h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">a = tuple()</span><br><span class="line">a = ()</span><br></pre></td></tr></table></figure>

<h4 id="2-元组的操作"><a href="#2-元组的操作" class="headerlink" title="2.元组的操作"></a>2.<strong>元组的操作</strong></h4><ul>
<li>访问</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a[0]   #代表元组a的下标为1的元素</span><br></pre></td></tr></table></figure>

<ul>
<li><p>增加：元组无法实现a[1] &#x3D; 5增加操作，<strong>元组的元素值是不能修改的</strong></p>
</li>
<li><p>删除</p>
</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">del a[x] #x代表元素下标的索引</span><br></pre></td></tr></table></figure>

<ul>
<li><p>修改：元组修改可以通过两个元组拼接来实现，元组的元素值是不能修改的</p>
</li>
<li><p>元组的个数</p>
</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">len(a)</span><br></pre></td></tr></table></figure>

<ul>
<li>元组的最大值</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">max(a)</span><br></pre></td></tr></table></figure>

<ul>
<li>元组的最小值</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">min(a)</span><br></pre></td></tr></table></figure>

<p><strong><em>注意：元组的元素值是不能修改的</em></strong></p>
<h3 id="九-集合"><a href="#九-集合" class="headerlink" title="九.集合"></a>九.集合</h3><h4 id="1-集合的创建"><a href="#1-集合的创建" class="headerlink" title="1.集合的创建"></a>1.<strong>集合的创建</strong></h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a = set()</span><br></pre></td></tr></table></figure>

<h4 id="2-集合的操作"><a href="#2-集合的操作" class="headerlink" title="2.集合的操作"></a>2.<strong>集合的操作</strong></h4><ul>
<li>访问：集合无法访问单独元素</li>
<li>增加</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.add(x) 或者 a.update(x)   #x为增加的元素</span><br></pre></td></tr></table></figure>

<ul>
<li>删除</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">a.remove(x)</span><br><span class="line">a.discard(x)</span><br><span class="line">a.pop()     </span><br><span class="line">#x代表移除的元素，第二种若元素不存在会出错，所以建议使用第一种方法,第三种为随机删除</span><br></pre></td></tr></table></figure>

<ul>
<li>修改：集合修改可以通过两个集合 &amp;|^+- 来实现</li>
<li>集合的个数</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">len(a)</span><br></pre></td></tr></table></figure>

<ul>
<li>复制集合</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.copy()</span><br></pre></td></tr></table></figure>

<ul>
<li>判断元素x是否在集合存在</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">x in s   #为存在返回True,否则False</span><br></pre></td></tr></table></figure>

<ul>
<li>清空集合</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.clear()</span><br></pre></td></tr></table></figure>

<h3 id="十-字典"><a href="#十-字典" class="headerlink" title="十.字典"></a>十.字典</h3><h4 id="1-字典的组成：a-‘键’-值-，由一个个键值对组成"><a href="#1-字典的组成：a-‘键’-值-，由一个个键值对组成" class="headerlink" title="1.字典的组成：a &#x3D; {‘键’:值}，由一个个键值对组成"></a>1.<strong>字典的组成：a &#x3D; {‘键’:值}，由一个个键值对组成</strong></h4><h4 id="2-字典的创建"><a href="#2-字典的创建" class="headerlink" title="2.字典的创建"></a>2.<strong>字典的创建</strong></h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">a = dict()</span><br><span class="line">a = &#123;&#125;</span><br></pre></td></tr></table></figure>

<h4 id="3-字典的操作"><a href="#3-字典的操作" class="headerlink" title="3.字典的操作"></a>3.<strong>字典的操作</strong></h4><ul>
<li>读取</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a[&#x27;x&#x27;]   #x代表读取元素的键，返回其值</span><br></pre></td></tr></table></figure>

<ul>
<li>增加</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a[&#x27;x&#x27;] = y   #x代表增加的元素的键，y代表增加元素的值</span><br></pre></td></tr></table></figure>

<ul>
<li>删除</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">del a[&#x27;x&#x27;]   #x代表删除元素的键</span><br></pre></td></tr></table></figure>

<ul>
<li>修改</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a[&#x27;x&#x27;] = y   #把x的值修改成y</span><br></pre></td></tr></table></figure>

<ul>
<li>字典的长度</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">len(a)</span><br></pre></td></tr></table></figure>

<ul>
<li>清空字典</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.clear()</span><br></pre></td></tr></table></figure>

<ul>
<li>复制字典</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.copy()</span><br></pre></td></tr></table></figure>

<ul>
<li>随机返回字典某一键值对</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.item()</span><br></pre></td></tr></table></figure>

<ul>
<li>返回某一元素对应的值</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.get(&#x27;x&#x27;)   # x为改元素的键</span><br></pre></td></tr></table></figure>

<ul>
<li>返回所有元素对应的值</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.values()</span><br></pre></td></tr></table></figure>

<ul>
<li>返回所有元素对应的键</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.keys()</span><br></pre></td></tr></table></figure>

<ul>
<li>随机返回并删除该键值对</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.popitem()</span><br></pre></td></tr></table></figure>

<p><strong>注_意：键值对的键是唯一的，不能出现两个相同的键，值是可变的_</strong></p>
<h3 id="十一-函数"><a href="#十一-函数" class="headerlink" title="十一.函数"></a>十一.函数</h3><h4 id="1-格式："><a href="#1-格式：" class="headerlink" title="1.格式："></a>1.<strong>格式：</strong></h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">    def 变量名(参数一,参数二):</span><br><span class="line">        (表达式一)</span><br></pre></td></tr></table></figure>

<p><strong><strong><em>注意：在Python中可以有返回值，也可以不有返回值，还可以只有 return</em></strong></strong></p>
<h4 id="2-函数的调用"><a href="#2-函数的调用" class="headerlink" title="2.函数的调用"></a>2.<strong>函数的调用</strong></h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">def count(a,b):    #定义函数count，参数为a，b</span><br><span class="line">   return a+b    #返回a+b的值</span><br><span class="line"></span><br><span class="line">m = count(1,2)   #此处进行了函数的调用</span><br><span class="line">print(m)</span><br><span class="line"></span><br><span class="line">&gt;&gt;3</span><br></pre></td></tr></table></figure>

<h3 id="十二-类"><a href="#十二-类" class="headerlink" title="十二.类"></a>十二.类</h3><h4 id="1-关键字：class"><a href="#1-关键字：class" class="headerlink" title="1.关键字：class"></a>1.<strong>关键字：class</strong></h4><h4 id="2-格式"><a href="#2-格式" class="headerlink" title="2.格式"></a>2.<strong>格式</strong></h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">class (变量名1):</span><br><span class="line">      def __init__(self,参数一,参数二...):</span><br><span class="line">         self.变量名2 = 参数一    #此处的变量名2为实列变量</span><br><span class="line">      def __del__(self):    #不常用，再出现结束前一部进行</span><br><span class="line">         表达式1</span><br><span class="line">      def __str__(self):    #必须返回字符串</span><br><span class="line">         return &quot;此处为一个字符串&quot;</span><br><span class="line">      def 变量名3(self):    #实列方法</span><br><span class="line">         表达式2</span><br></pre></td></tr></table></figure>

<h4 id="3-类调用"><a href="#3-类调用" class="headerlink" title="3.类调用"></a>3.<strong>类调用</strong></h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a = 变量名1(参数一,参数二...)</span><br></pre></td></tr></table></figure>

<p>完毕，后续有待补充，欢迎各位大佬指出错误，多谢！</p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="http://www.lijunxi.site">Jixer</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="http://www.lijunxi.site/posts/695896537/">http://www.lijunxi.site/posts/695896537/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://www.lijunxi.site" target="_blank">Jixer的小屋</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/Python/">Python</a></div><div class="post_share"><div class="social-share" data-image="https://q1.qlogo.cn/g?b=qq&amp;nk=2770063826&amp;s=640" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="/pluginsSrc/butterfly-extsrc/sharejs/dist/css/share.min.css?v=1.1.3" media="print" onload="this.media='all'"><script src="/pluginsSrc/butterfly-extsrc/sharejs/dist/js/social-share.min.js?v=1.1.3" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/3014530432/" title="C语言错题集"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">C语言错题集</div></div></a></div><div class="next-post pull-right"><a href="/posts/3447396109/" title="C语言指针"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">C语言指针</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="" data-original="https://q1.qlogo.cn/g?b=qq&amp;nk=2770063826&amp;s=640" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Jixer</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">52</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">19</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">7</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/2770063826"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content"></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%80-Python%E7%9A%84%E5%AE%89%E8%A3%85%E4%B8%8E%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA"><span class="toc-text">一.Python的安装与环境搭建</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BA%8C-%E7%AC%AC%E4%B8%80%E4%B8%AAPython%E7%A8%8B%E5%BA%8F"><span class="toc-text">二.第一个Python程序</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%89-Python%E7%9A%84%E5%9F%BA%E7%A1%80%E8%AF%AD%E6%B3%95"><span class="toc-text">三.Python的基础语法</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-Python%E7%9A%84%E6%A0%87%E8%AF%86%E7%AC%A6"><span class="toc-text">1.Python的标识符</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-Python%E7%9A%84%E5%85%B3%E9%94%AE%E5%AD%97"><span class="toc-text">2.Python的关键字</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-Python%E7%9A%84%E6%B3%A8%E9%87%8A"><span class="toc-text">3.Python的注释</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#4-Python%E7%9A%84%E7%BC%A9%E8%BF%9B"><span class="toc-text">4.Python的缩进</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9B%9B-Python%E7%9A%84%E5%9F%BA%E6%9C%AC%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B"><span class="toc-text">四.Python的基本数据类型</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-Python%E4%B8%AD%E7%9A%84%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B"><span class="toc-text">1.Python中的数据类型</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E6%AF%8F%E4%B8%AA%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E4%B9%8B%E9%97%B4%E8%83%BD%E7%9B%B8%E4%BA%92%E8%BD%AC%E6%8D%A2"><span class="toc-text">2. 每个数据类型之间能相互转换</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BA%94-%E6%9D%A1%E4%BB%B6%E5%88%A4%E6%96%AD%E8%AF%AD%E5%8F%A5%EF%BC%88%E6%AF%94%E8%BE%83%E7%AE%80%E5%8D%95%E5%B0%B1%E4%B8%8D%E5%86%8D%E8%BF%87%E5%A4%9A%E5%8F%99%E8%BF%B0%EF%BC%89"><span class="toc-text">五.条件判断语句（比较简单就不再过多叙述）</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%A0%BC%E5%BC%8F%EF%BC%9A"><span class="toc-text">格式：</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%AD-%E5%BE%AA%E7%8E%AF%E8%AF%AD%E5%8F%A5%EF%BC%88%E6%AF%94%E8%BE%83%E7%AE%80%E5%8D%95%E5%B0%B1%E4%B8%8D%E5%86%8D%E8%BF%87%E5%A4%9A%E5%8F%99%E8%BF%B0%EF%BC%89"><span class="toc-text">六.循环语句（比较简单就不再过多叙述）</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-while%E5%BE%AA%E7%8E%AF"><span class="toc-text">1.while循环</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-for%E5%BE%AA%E7%8E%AF"><span class="toc-text">2.for循环</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%83-%E5%88%97%E8%A1%A8"><span class="toc-text">七.列表</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E5%88%97%E8%A1%A8%E7%9A%84%E5%88%9B%E5%BB%BA"><span class="toc-text">1.列表的创建</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E5%88%97%E8%A1%A8%E7%9A%84%E6%93%8D%E4%BD%9C"><span class="toc-text">2.列表的操作</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%AB-%E5%85%83%E7%BB%84"><span class="toc-text">八.元组</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E5%85%83%E7%BB%84%E7%9A%84%E5%88%9B%E5%BB%BA"><span class="toc-text">1.元组的创建</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E5%85%83%E7%BB%84%E7%9A%84%E6%93%8D%E4%BD%9C"><span class="toc-text">2.元组的操作</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B9%9D-%E9%9B%86%E5%90%88"><span class="toc-text">九.集合</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E9%9B%86%E5%90%88%E7%9A%84%E5%88%9B%E5%BB%BA"><span class="toc-text">1.集合的创建</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E9%9B%86%E5%90%88%E7%9A%84%E6%93%8D%E4%BD%9C"><span class="toc-text">2.集合的操作</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8D%81-%E5%AD%97%E5%85%B8"><span class="toc-text">十.字典</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E5%AD%97%E5%85%B8%E7%9A%84%E7%BB%84%E6%88%90%EF%BC%9Aa-%E2%80%98%E9%94%AE%E2%80%99-%E5%80%BC-%EF%BC%8C%E7%94%B1%E4%B8%80%E4%B8%AA%E4%B8%AA%E9%94%AE%E5%80%BC%E5%AF%B9%E7%BB%84%E6%88%90"><span class="toc-text">1.字典的组成：a &#x3D; {‘键’:值}，由一个个键值对组成</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E5%AD%97%E5%85%B8%E7%9A%84%E5%88%9B%E5%BB%BA"><span class="toc-text">2.字典的创建</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-%E5%AD%97%E5%85%B8%E7%9A%84%E6%93%8D%E4%BD%9C"><span class="toc-text">3.字典的操作</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8D%81%E4%B8%80-%E5%87%BD%E6%95%B0"><span class="toc-text">十一.函数</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E6%A0%BC%E5%BC%8F%EF%BC%9A"><span class="toc-text">1.格式：</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E5%87%BD%E6%95%B0%E7%9A%84%E8%B0%83%E7%94%A8"><span class="toc-text">2.函数的调用</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8D%81%E4%BA%8C-%E7%B1%BB"><span class="toc-text">十二.类</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E5%85%B3%E9%94%AE%E5%AD%97%EF%BC%9Aclass"><span class="toc-text">1.关键字：class</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E6%A0%BC%E5%BC%8F"><span class="toc-text">2.格式</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-%E7%B1%BB%E8%B0%83%E7%94%A8"><span class="toc-text">3.类调用</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/posts/2029624507/" title="2022年算法队选拔赛">2022年算法队选拔赛</a><time datetime="2024-05-09T15:00:27.000Z" title="发表于 2024-05-09 23:00:27">2024-05-09</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/posts/1978524057/" title="牛客小白月赛84">牛客小白月赛84</a><time datetime="2024-05-08T14:40:35.000Z" title="发表于 2024-05-08 22:40:35">2024-05-08</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/posts/131339317/" title="软件测试资料">软件测试资料</a><time datetime="2024-05-07T03:12:52.000Z" title="发表于 2024-05-07 11:12:52">2024-05-07</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/posts/2394234105/" title="第十四届蓝桥杯B组国赛">第十四届蓝桥杯B组国赛</a><time datetime="2024-05-05T13:40:15.000Z" title="发表于 2024-05-05 21:40:15">2024-05-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/posts/1405472621/" title="Leetcode第396场周赛">Leetcode第396场周赛</a><time datetime="2024-05-05T03:58:25.000Z" title="发表于 2024-05-05 11:58:25">2024-05-05</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2024 By Jixer</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text"><a href="https://beian.miit.gov.cn/#/Integrated/index" style="color:white" target="_blank">蜀ICP备2022009955号-1</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js?v=4.13.0"></script><script src="/js/main.js?v=4.13.0"></script><script src="/pluginsSrc/@fancyapps/ui/dist/fancybox/fancybox.umd.js?v=5.0.33"></script><div class="js-pjax"></div><script src="/js/custom-fancybox-umd-min.js"></script><script src="/js/custom-busuanzi-pure-mini.js"></script><script src="/js/Valine.min.js"></script><script src="/js/custom-social-share.min.js"></script><script src="/js/custom-typed-umd-min.js"></script><script src="/js/av-min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js?v=4.13.0"></script></div></div>
        <style>
            [bg-lazy] {
                background-image: none !important;
                background-color: #eee !important;
            }
        </style>
        <script>
            window.imageLazyLoadSetting = {
                isSPA: false,
                preloadRatio: 1,
                processImages: null,
            };
        </script><script>window.addEventListener("load",function(){var t=/\.(gif|jpg|jpeg|tiff|png)$/i,r=/^data:image\/[a-z]+;base64,/;Array.prototype.slice.call(document.querySelectorAll("img[data-original]")).forEach(function(a){var e=a.parentNode;"A"===e.tagName&&(e.href.match(t)||e.href.match(r))&&(e.href=a.dataset.original)})});</script><script>!function(r){r.imageLazyLoadSetting.processImages=t;var e=r.imageLazyLoadSetting.isSPA,n=r.imageLazyLoadSetting.preloadRatio||1,c=a();function a(){var t=Array.prototype.slice.call(document.querySelectorAll("img[data-original]")),e=Array.prototype.slice.call(document.querySelectorAll("[bg-lazy]"));return t.concat(e)}function t(){e&&(c=a());for(var t,o=0;o<c.length;o++)0<=(t=(t=c[o]).getBoundingClientRect()).bottom&&0<=t.left&&t.top<=(r.innerHeight*n||document.documentElement.clientHeight*n)&&function(){var t,e,n,a,i=c[o];e=function(){c=c.filter(function(t){return i!==t}),r.imageLazyLoadSetting.onImageLoaded&&r.imageLazyLoadSetting.onImageLoaded(i)},(t=i).hasAttribute("bg-lazy")?(t.removeAttribute("bg-lazy"),e&&e()):(n=new Image,a=t.getAttribute("data-original"),n.onload=function(){t.src=a,t.removeAttribute("data-original"),e&&e()},t.src!==a&&(n.src=a))}()}function i(){clearTimeout(t.tId),t.tId=setTimeout(t,500)}t(),document.addEventListener("scroll",i),r.addEventListener("resize",i),r.addEventListener("orientationchange",i)}(this);</script></body></html>